home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / System / appe Windows / About appe Windows < prev    next >
Encoding:
Text File  |  1994-05-23  |  5.6 KB  |  144 lines  |  [TEXT/R*ch]

  1. appe Windows
  2.  
  3. If you have seen the new Speech Manager, then you know that a background
  4. only application can put a window onto the screen (contrary to popular
  5. belief). The new Text Services Manager in System 7.1 offers documented
  6. hooks for creating, disposing, and handling floating windows. These
  7. windows are layer independent (they are floating above all programs
  8. and windows), and work without patching traps (well, a quick jGNEFilter,
  9. but no traps).
  10.  
  11. This program demonstrates a shell application that puts a TSM window
  12. onto the screen, and intercepts update, click, and key events. Filling
  13. in the handler functions is the easiest way to put up your own floater.
  14. Wrapper functions restore global context, current resource file, GrafPort, 
  15. and heap zone, to make standard handling routines much easier to write.
  16.  
  17. Of course the program is background only, so it is typically launched
  18. from the Extensions Folder at startup. I like the close box on floater
  19. windows, because its an easy way to quit the program without relying
  20. on a quit Apple Event. I have added support for hiding all windows
  21. with Cmd-Escape, and to respond to screen savers and programs that
  22. take over the screen (hide the menu bar).
  23.  
  24.  
  25. Legal Stuff
  26.  
  27. Its yours if you like it. This shell is free for you to modify and
  28. expand upon. I would like that you tell me if you use this, but you
  29. are under no obligation. Likewise, this library is provided as is --
  30. I fixed up all the bugs I could find/create, so I could use it myself --
  31. but that doesnt necessarily mean its fit for wiping the toilet seat. :)
  32.  
  33.  
  34. Using the library
  35.  
  36. In scanning the source for the program, there are several key areas
  37. that you should recognize. These gotchas are important things to 
  38. remember when modifying or adding to the source.
  39.  
  40. main.c
  41.     
  42.     Creating and using Text Service windows requires additional
  43.     stack space. I found that 16k of additional stack seems to
  44.     work. BTW, keep the memory footprint down (cuz people dont like
  45.     memory hogs) but not too small or you will have heap space
  46.     problems. I had to fine tune my demo apps to work well in
  47.     limited memory space.
  48.     
  49.     The only Toolbox initialization call that you should make
  50.     is InitGraf() to setup the QD globals. InitWindows() plays
  51.     with the layer manager in a bad way, and should be avoided.
  52.     
  53.     I use Gestalt() to check my environment, and exit gracefully
  54.     with a Notification Mgr dialog.
  55.     
  56. windows.c
  57.  
  58.     The current TSM does not create a Color Window for us, so there
  59.     is a #define in "main.h" that gives you the option to patch
  60.     traps. Although this violates our promise of Patch-Free operation,
  61.     it gives us color -- so lose or leave it at your whim.
  62.     
  63.     Hooks are set up for you to implement the following window
  64.     functions: Update, Click, Keydowns, Zoom, Reveal (on show
  65.     and hide), and Idle time.
  66.  
  67.     Key events can be intercepted or passed through at your 
  68.     discretion. By default, only Cmd-Escape is applicable and
  69.     it is passed through so that other floaters can see it. 
  70.     (This would be a useful feature for all similar apps to 
  71.     implement, please?)
  72.     
  73.     Controls like scroll bars or other window-activation 
  74.     sensitive elements should always be active in floaters,
  75.     since all floaters are considered active regardless of
  76.     position in window list.
  77.     
  78. event filter.c
  79.  
  80.     The jGNEFilter is the best way to intercept the events
  81.     directed at our window. We check mouse and key events
  82.     for relevance, and then convert them to null events
  83.     if directed at our window.
  84.     
  85.     Note: for some reason, we miss occasional mouse-downs.
  86.     I think it may be a bug in the TSM.
  87.     
  88.     Our floaters dont get update events either, so we manually
  89.     check the update region of our window and call the update
  90.     routine. We have to check every event because update events
  91.     aren't necessarily posted when just our window needs
  92.     drawing.
  93.     
  94.     Contexts are the mechanism we use for setting up and cleaning
  95.     up relevant variables and registers. A context struct
  96.     defines some major elements that I need. Be sure that code
  97.     you add is not dependent on other lo-mem globals without the
  98.     right save and restore context wrappers. Also, since a
  99.     context plays with A5 and your app globals, you have to
  100.     be careful about globally stored contexts.
  101.     
  102.     To get information about the front application, you may need
  103.     to restore its context (to get heap info or access private
  104.     globals off A5). Be sure to carefully manage when you are
  105.     using your apps context and someone elses.
  106.     
  107. Other notes
  108.     
  109.     In "main.h" I define a Hot Application, which lets you tie
  110.     your floater to an particular application creator type. If
  111.     you change this value, your floaters will only be visible 
  112.     when that application is the front program. This is a great
  113.     way to give specialized information about a particular 
  114.     program without modifying it.
  115.     
  116.     Perhaps it would be better to handle events within my own
  117.     event loop, but since there is no easy way to PostEvent()
  118.     from one apps context to another this is not done. If you
  119.     have a suggestion to help me, I would like to make this
  120.     change.
  121.  
  122. Anticipated Improvements:
  123.     
  124.     Adding basic menu support for Quit and Show/Hide so that
  125.     the "Background Only" bit can be toggled. It was suggested
  126.     that this may be a useful thing for those who want to 
  127.     launch or quit the app several times.
  128.     
  129.     Making a small LaunchMe and QuitMe drag/drop utils that 
  130.     do no File Type checking for our convenience.
  131.     
  132.     Handle window events inside my own event loop by grabbing them
  133.     and putting them into my own Event Queue.
  134.     
  135.     Anything else you can think of?
  136.  
  137. Finally, I want this to be a stable mechanism for something that you
  138. shouldn't be able to do. Despite the interface guidelines, there may
  139. be a use for doing this. Please send me bug reports and suggestions
  140. for improving this tool.
  141.  
  142. Matt Slot
  143. fprefect@engin.umich.edu
  144.